﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KML
{
    public class KMLFolder : MarshalByRefObject
    {
        string name;
        string fullName;
        string descr;
        float visibility;

        List<KMLPlacemark> placemarks;
        List<KMLNetworkLink> nlinks;
        List<KMLFolder> folders;

        internal KMLFolder(string name, string descr, float vis, List<KMLFolder> subfolders, List<KMLPlacemark> placemarks, List<KMLNetworkLink> nlinks, string rootName)
        {
            this.name = name;
            this.fullName = rootName + "/" + name;
            this.descr = descr;
            this.visibility = vis;
            this.placemarks = placemarks;
            this.nlinks = nlinks;
            this.folders = subfolders;

            if (folders == null) folders = new List<KMLFolder>();
            if (nlinks == null) nlinks = new List<KMLNetworkLink>();
            if (placemarks == null) placemarks = new List<KMLPlacemark>();
        }

        public string Name { get { return name; } }
        public string FullName { get { return fullName; } }
        public string Description { get { return descr; } }
        public float Visibility { get { return visibility; } }
        public List<KMLFolder> Folders { get { return folders; } }
        public List<KMLPlacemark> Placemarks { get { return placemarks; } }
        public List<KMLNetworkLink> NetworkLinks { get { return nlinks; } }

        public override string ToString()
        {
            return string.Format("{0} ({1} subfolders, {2} placemarks, {3} network links)", name, 
                folders == null ? 0 : folders.Count, placemarks == null ? 0 : placemarks.Count,
                nlinks == null ? 0 : nlinks.Count);
        }
    }
}
